/**
*      author: Y_Yao
*      created: 2025-04-21 16:59:16
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 20 + 7;
int n,m;
bool vis[2007];
int a[N];
int f[N];
int mx,ans;

void check()
{
    int sum = 0;
    for(int i = 1;i <= n;i++)
    {
        if(f[i]) continue;
        for(int j = sum;j >= 0;j--)
        {
            if(vis[j] && !vis[j + a[i]])
            {
                vis[j + a[i]] = true;
                ans++;
            }
        }
        sum += a[i];
    }
}

void dfs(int pos,int num)
{
    if(num == m)
    {
        memset(vis,0,sizeof(vis));
        vis[0] = 1,ans = 0;
        check();
        mx = max(mx,ans);
        return;
    }
    for(int i = pos;i <= n;i++)
    {
        f[i] = 1;
        dfs(i + 1,num + 1);
        f[i] = 0;
    }
}


void solve()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i++) cin >> a[i];

    dfs(1,0);

    cout << mx << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}